Chris Lacy's Software Engineering Blog
coc rest - now with schemas!
- post whatever, in whatever format
- retrieve in whatever format
- add schema before/after if you want (in language of choice - sql, Java, groovy, xml, etc)
- add security if you want (over coc)
- key/value cache with storage back
- translators
- cross kingdom impl to support favorite deploy (war, cgi, etc)
Posted at 02:34PM Aug 26, 2010 by chris in General |
the vm
i predict that a new vm will emerge
- designed for the cloud
- non proprietary
- may abstract jvm and/or .net
- @see xmlvm
- program to any supported api
- all open source apis become immediately available
- will be optimised for: grails, rails, scheme, and/or erlang
Posted at 02:21PM Aug 24, 2010 by chris in General |
802.11s - I am disappoint
I continue to have high hopes for 802.11s and more advanced networking in general. ISPs are no longer needed. All we need are ways to securely and fairly share our connectivity. Imagine you're using your netbook and want to access google, but there's no hotspot nearby. Luckily, there's a guy on his smart phone 100 feet away, and from there he has a signal to a company's wifi (on which he's making the call). That company has a large antenna that reaches google.
I see lots of potential here. You can exchange bandwidth for equal bandwidth, and receive cash if you run a surplus. Municipalities would only need one connection to internet backbone instead of running wires to each residence. Anyone can run a website/server. It's the future.
Posted at 11:35AM Jul 27, 2010 by chris in General |
object translators
in the year 2000, the buzz will be object translators, aka, property editors, aka closures, aka un/marshallers, aka de/serializers, aka reflected methods, etc. and everyone will conform to a standard api
we'll have libraries of translators, too; and we'll define the rules by which a given translator is chosen for conversion between types. and we'll have translators that don't have return values, and translators that take multiple values, etc
and what we'll do, is, we'll pipe data between these translators and translator libraries. REST will be piping data from a web request to a translator that converts http messages to sql (with maybe JSON or XML or AMF in between, plus validation/exception handling and security)
but we'll add these "plus" features (exception handling, security, caching, etc) with aop and additional translators/libraries
Posted at 08:35PM Jun 26, 2010 by chris in General |
finite state machines, domain specific languages, and abstract resources
prediction: we're going to see a convergence around a domain specific language for constructing finite state machines that act on abstract resources. for example, web flow "languages", enterprise service buses, and enterprise integration technologies will eventually share a common tongue. we may see this vertically as well: how many (virtual) machine languages do we need? and since machine languages are themselves programming languages, can we consolidate? do we really need multiple data access technologies (rest, sql, no-sql, hql, jpql)? how many times are we going to re-invent distributed middleware (corba, rmi, rmi-iiop, soap)?
back to finite state machines, though. just as there are enterprise integration patterns, there will be semi-solid "strategies" which take pluggable abstract resources. those resources may be determined by the environment ala osgi di.
Posted at 12:19AM Jun 17, 2010 by chris in General |
Grails AJAJ Autocomplete
Currently only working with grails 1.2-M3 (grails-ui plugin fails in M4)
package net.chrislacy.grails
import grails.converters.JSON
import java.util.concurrent.ConcurrentSkipListSet
class AjajController {
static names = ['Blaire','Carol','Chris','Christy','Conan','Heather','Olivia'] as ConcurrentSkipListSet
def index = {[names:names]}
def autoCompleteMe = {
def query = params.query
def next = query + Character.MAX_VALUE
def foundNames = names.subSet(query, true, next, true).collect{[name:it]}
render([result:foundNames] as JSON)
}
def add = {render names << params.name}
}
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>AJAJ Example</title>
<gui:resources components="['autoComplete']"/>
<g:javascript library="prototype" />
</head>
<body>
<g:formRemote name="add" url="[controller:'ajaj', action:'add']" update="update">
<gui:autoComplete name="name" controller="ajaj" action="autoCompleteMe" minQueryLength="1" />
<g:submitButton style="display:none" name="add"/>
</g:formRemote>
<div id="update">${names}</div>
</body>
</html>
Posted at 08:56PM Nov 26, 2009 by chris in General |
Grails Makes AJAX Too Easy
package net.chrislacy.grails
class AjaxController {
static Set names = new TreeSet()
static {
names << 'Al'
names << 'Barry'
names << 'Carol'
names << 'Chris'
names << 'Conan'
names << 'Olivia'
names << 'Sandy'
names << 'Sam'
}
def index = {
def model =[:]
model.names = names
model
}
def searchAJAX = {
Set foundNames = names.collect(new TreeSet()) {
it.startsWith(params.query) ? it : ''
}
foundNames.remove ''
render(contentType: "text/xml") {
results() {
foundNames.each { n ->
result() {
name(n)
}
}
}
}
}
def add = {
names << params.name
render names
}
}
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ajax Example</title>
<resource:autoComplete skin="default"/>
<g:javascript library="scriptaculous" />
</head>
<body>
<g:formRemote name="add" url="[controller:'ajax', action:'add']" update="update">
<richui:autoComplete name="name" action="${createLinkTo('dir': 'ajax/searchAJAX')}"/>
</g:formRemote>
<div id="update">${names}</div>
</body>
</html>
Live: http://chrislacy.net/AjaxExample/
Posted at 06:42PM Nov 23, 2009 by chris in General |
SOAP is to CORBA as REST is to _
Remember the SATs?
SOAP is to CORBA as REST is to _
A. Java
B. RPC
C. A Database language like SQL
D. Clean, sleepy snakes
Posted at 09:04PM Apr 05, 2009 by chris in General |
Exception Handling
I'm a big fan of the Spring Framework. Their motto, when it comes to exception handling, is: throw unchecked exceptions unless you have a good reason not to (paraphrase). This allows you to place your error handling code at places that make sense, without the clutter of catching or declaring checked exceptions. Throwing unchecked exceptions keeps your code clean, and promotes the good practice of identifying key points within your code where exceptional events may be properly handled, often through a user message and a log action.
It would be nice to add some sort of warning to code that has a high likelihood of throwing an exception, without needing to explicitly handle the exception. For example, declared unchecked exceptions might produce compiler warnings if they are not caught or re-thrown. This would act as a friendly reminder to engineers that they need to account for exceptional conditions, and they might want to add extra error handling around this method if there's something they think they can do.
Another option my be a new class of exceptions that lie between checked and unchecked. Not handling them would produce warnings through the potential call stack.
Posted at 07:39AM Feb 01, 2009 by chris in General |
Hibernate using JPA Annotations in One Eclipse Project
I finally put together a small Java web app that has all of my favorite tools: Spring, Hibernate, JPA annotations, and Maven (m2eclipse); all in one Eclipse project. If you've ever tried to get these to work together you know it can be a hassle. Recent improvements in m2eclipse have made things a lot easier. For this blog entry I want to share with you one of the last pieces of my puzzle.
My understanding is that the Spring/Hibernate combination works in two modes: Hibernate and JPA. In both modes you can scan for annotated entities, but in the JPA mode the scan depends on EJB3 package compilation artifacts. I could have tried creating a separate project for the EJBs, but imo that's too much work, especially when you get Maven involved. Instead, I dove into the Spring and Hibernate internals and hacked together my own solution. Then, of course, I read this blog post (warning, language), and followed up by exploring loom. They use a bean post processor, which is much cleaner than my hack. Here's the low down:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource">
<property name="persistenceUnitPostProcessors">
<bean class="net.chrislacy.webapp.HibernateJpaPostProcessor" p:packages="net.chrislacy.webapp"/>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="HSQL"
p:showSql="false"
p:generateDdl="true">
</bean>
</property>
<property name="persistenceXmlLocation" value="/META-INF/persistence.xml" />
</bean>
public class HibernateJpaPostProcessor implements PersistenceUnitPostProcessor, InitializingBean {
private ClassPathScanningCandidateComponentProvider provider;
private String[] packages = new String[] {};
/**
* Search for persistent classes under the configured folders and register
* them in the persistence unit.
*/
public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo unit) {
for (String pakage : packages) {
for (BeanDefinition bean : provider.findCandidateComponents(pakage)) {
unit.addManagedClassName(bean.getBeanClassName());
}
}
}
public void afterPropertiesSet() {
if (provider == null) {
provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AnnotationTypeFilter(Entity.class, false));
}
}
public void setProvider(ClassPathScanningCandidateComponentProvider provider) {
this.provider = provider;
}
public void setPackages(String[] packages) {
this.packages = packages;
}
}
Posted at 08:21PM Sep 07, 2008 by chris in General |