This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apollo Contributor License Agreement | |
In order to clarify the intellectual property license granted with Contributions from any person or entity, the open source project Apollo ("Apollo") must have a Contributor License Agreement (CLA) on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of Apollo and its users; it does not change your rights to use your own Contributions for any other purpose. | |
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Apollo. Except for the license granted herein to Apollo and recipients of software distributed by Apollo, You reserve all right, title, and interest in and to Your Contributions. | |
1. Definitions. "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Apollo. For legal entities, the entity making a Contri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Escaper pathEscapers = UrlEscapers.urlPathSegmentEscaper(); | |
Escaper queryEscapers = UrlEscapers.urlFormParameterEscaper(); | |
Escaper fragmentEscaper= UrlEscapers.urlFragmentEscaper(); | |
String path1 = "somePathWithSpace "; | |
String path2 = "somePathWith中文AndPlus+"; | |
String someKeyword = "someKeywordWith中文AndPlus+AndSpace "; | |
String someFragment = "someFragmentWithSpace "; | |
String url = String.format( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Config config = ConfigService.getConfig("FX.Hermes.Producer"); | |
config.addChangeListener(new ConfigChangeListener() { | |
@Override | |
public void onChange(ConfigChangeEvent changeEvent) { | |
System.out.println("Changes for namespace " + changeEvent.getNamespace()); | |
for (String key : changeEvent.changedKeys()) { | |
ConfigChange change = changeEvent.getChange(key); | |
System.out.println(String.format( | |
"Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", | |
change.getPropertyName(), change.getOldValue(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Config config = ConfigService.getConfig("FX.Hermes.Producer"); | |
Integer defaultSenderBatchSize = 200; | |
Integer senderBatchSize = config.getIntProperty("sender.batchsize", defaultSenderBatchSize); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Config config = ConfigService.getAppConfig(); | |
config.addChangeListener(new ConfigChangeListener() { | |
@Override | |
public void onChange(ConfigChangeEvent changeEvent) { | |
for (String key : changeEvent.changedKeys()) { | |
ConfigChange change = changeEvent.getChange(key); | |
System.out.println(String.format( | |
"Found change - key: %s, oldValue: %s, newValue: %s, changeType: %s", | |
change.getPropertyName(), change.getOldValue(), | |
change.getNewValue(), change.getChangeType())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Config config = ConfigService.getAppConfig(); | |
Integer defaultRequestTimeout = 200; | |
Integer requestTimeout = config.getIntProperty("requestTimeout", defaultRequestTimeout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/notifications") | |
public class NotificationControllerSample implements MessageListener { | |
@Autowired | |
private EntityManagerUtil entityManagerUtil; | |
private List<String> findWatchedKeys(String applicationId, String namespace, | |
String dataCenter) { | |
List<String> watchedKeys = Lists.newArrayList(); | |
//do more logic, may need to load from db in some cases |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DispatcherServlet extends FrameworkServlet { | |
protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception { | |
... | |
// Actually invoke the handler. | |
mv = ha.handle(processedRequest, response, mappedHandler.getHandler()); | |
if (asyncManager.isConcurrentHandlingStarted()) { | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAccessor implements AsyncWebRequestInterceptor { | |
@Override | |
public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException { | |
if (!decrementParticipateCount(request)) { | |
EntityManagerHolder emHolder = (EntityManagerHolder)TransactionSynchronizationManager.unbindResource(getEntityManagerFactory()); | |
logger.debug("Closing JPA EntityManager in OpenEntityManagerInViewInterceptor"); | |
EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/notifications") | |
public class NotificationControllerSample implements MessageListener { | |
private static final long TIMEOUT = 360 * 60 * 1000;//6 hours | |
private final Multimap<String, DeferredResult<ResponseEntity<ApolloConfigNotification>>> | |
deferredResults = Multimaps.synchronizedSetMultimap(HashMultimap.create()); | |
private static final ResponseEntity<ApolloConfigNotification> | |
NOT_MODIFIED_RESPONSE = new ResponseEntity<>(HttpStatus.NOT_MODIFIED); | |
@RequestMapping(method = RequestMethod.GET) |
NewerOlder